//
//  NSString+ChineseTransForm.m
//  TodatPlay
//
//  Created by dllo on 16/9/22.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "NSString+ChineseTransForm.h"

@implementation NSString (ChineseTransForm)
#pragma mark - 将中文转换成拼音
+ (NSString *)transform:(NSString *)chinese{
    //将NSString装换成NSMutableString
    NSMutableString *pinyin = [chinese mutableCopy];
    
    //将汉字转换为拼音(带音标)
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
//    NSLog(@"%@", pinyin);
    
    //去掉拼音的音标
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);
//    NSLog(@"%@", pinyin);
    
    //返回最近结果
    return pinyin;
    
}

@end
